package com.shxzz.easy12306.services.pay.dto.convert;

import cn.hutool.core.bean.BeanUtil;
import com.shxzz.easy12306.services.pay.common.enums.PayChannelEnum;
import com.shxzz.easy12306.services.pay.dto.ali.AliPayRequest;
import com.shxzz.easy12306.services.pay.dto.base.PayRequest;
import com.shxzz.easy12306.services.pay.dto.req.PayCommand;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * 支付请求转换工具类
 * @author shxzz
 * @create 2024-03-11-22:44
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class PayCommandConvert {

    public static PayRequest convert(PayCommand payCommand) {
        PayRequest payRequest = null;
        if (Objects.equals(payCommand.getChannel(), PayChannelEnum.ALI_PAY.getCode())) {
            payRequest = BeanUtil.toBean(payCommand, AliPayRequest.class);
        }
        return payRequest;
    }
}
